const acorn = require('acorn');

const walk = require('./walk');

const astTree = acorn.parse(`import $ from 'jquery';`,{
  locations: true, //该 块 在源码中的位置 (start,end)
  ranges: true,
  sourceType: 'module',
  // ecmaVersion: "latest"
});
let ident = 0;
const padding = () => " ".repeat(ident);

//遍历结构查看 walk.jpg
astTree.body.forEach(statement => {
  walk(statement,{
    enter(node) {
      if (node.type){
        console.log(padding() +node.type);
        ident+=2;
      }
    },
    leave(node){
      if(node.type){
        ident -= 2;
        console.log(padding() + node.type);
      }
    }
  })
});
